package com.ruoyi.environment.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.environment.domain.OpmEnvParkWaste;
import com.ruoyi.environment.service.IOpmEnvParkWasteService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 园区出渣Controller
 *
 * @author cjie
 * @date 2021-12-14
 */
@Api(tags = " 园区出渣")
@RestController
@RequestMapping("/opmEnvParkWaste")
public class OpmEnvParkWasteController extends BaseController {
    @Autowired
    private IOpmEnvParkWasteService opmEnvParkWasteService;

    /**
     * 查询园区出渣列表
     */
    @ApiOperation(value="查询园区出渣列表", notes="查询园区出渣列表")
    @PreAuthorize(hasPermi = "environment:opmEnvParkWaste:list")
    @GetMapping("/list")
    public TableDataInfo list(OpmEnvParkWaste opmEnvParkWaste) {
        startPage();
        List<OpmEnvParkWaste> list = opmEnvParkWasteService.selectOpmEnvParkWasteList(opmEnvParkWaste);
        return getDataTable(list);
    }

    /**
     * 导出园区出渣列表
     */
    @ApiOperation(value="导出园区出渣列表", notes="导出园区出渣列表")
    @PreAuthorize(hasPermi = "environment:opmEnvParkWaste:export")
    @Log(title = "园区出渣", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OpmEnvParkWaste opmEnvParkWaste) throws IOException {
        List<OpmEnvParkWaste> list = opmEnvParkWasteService.selectOpmEnvParkWasteList(opmEnvParkWaste);
        ExcelUtil<OpmEnvParkWaste> util = new ExcelUtil<OpmEnvParkWaste>(OpmEnvParkWaste.class);
        util.exportExcel(response, list, "园区出渣数据");
    }
    /**
     * 获取园区出渣详细信息
     */
    @ApiOperation(value="获取园区出渣详细信息", notes="获取园区出渣详细信息")
    @PreAuthorize(hasPermi = "environment:opmEnvParkWaste:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(opmEnvParkWasteService.selectOpmEnvParkWasteById(id));
    }

    /**
     * 新增园区出渣
     */
    @ApiOperation(value="新增园区出渣", notes="新增园区出渣")
    @PreAuthorize(hasPermi = "environment:opmEnvParkWaste:add")
    @Log(title = "园区出渣", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OpmEnvParkWaste opmEnvParkWaste) {
        return toAjax(opmEnvParkWasteService.insertOpmEnvParkWaste(opmEnvParkWaste));
    }

    /**
     * 修改园区出渣
     */
    @ApiOperation(value="修改园区出渣", notes="修改园区出渣")
    @PreAuthorize(hasPermi = "environment:opmEnvParkWaste:edit")
    @Log(title = "园区出渣", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OpmEnvParkWaste opmEnvParkWaste) {
        return toAjax(opmEnvParkWasteService.updateOpmEnvParkWaste(opmEnvParkWaste));
    }

    /**
     * 删除园区出渣
     */
    @ApiOperation(value="删除园区出渣", notes="删除园区出渣")
    @ApiImplicitParam(name = "ids", value = "园区出渣ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "environment:opmEnvParkWaste:remove")
    @Log(title = "园区出渣", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(opmEnvParkWasteService.deleteOpmEnvParkWasteByIds(ids));
    }
}
